function C.RefreshGravity( ent )
	
	if( ent:GetClass() == "prop_ragdoll" ) then
		
		local phys = ent:GetPhysicsObject();
		
		if( ent.CurrentGravity == nil ) then
			
			ent.CurrentGravity = true;
			
		end
		
		local planet = C.InPlanet( ent );
		
		if( planet == 0 and ent.CurrentGravity ) then
			
			for i = 0, ent:GetPhysicsObjectCount() do
				
				local phys = ent:GetPhysicsObjectNum( i );
				if( phys and phys:IsValid() ) then
					phys:EnableGravity( false );
				end
				
			end
			
			ent.CurrentGravity = false;
			
		elseif( planet != 0 and !ent.CurrentGravity ) then
			
			for i = 0, ent:GetPhysicsObjectCount() do
				
				local phys = ent:GetPhysicsObjectNum( i );
				if( phys and phys:IsValid() ) then
					phys:EnableGravity( true );
					phys:Wake();
				end
				
			end
			
			ent.CurrentGravity = true;
			
		end
		
		return;
		
	end
	
	if( ent:IsPlayer() ) then
		
		if( !ent.CurrentGravity ) then
			
			ent.CurrentGravity = 1;
			ent:SetGravity( 1 );
			
		end
		
		local planet = C.InPlanet( ent );
		
		if( planet == 0 ) then
			
			local trace = { };
			trace.start = ent:GetPos();
			trace.endpos = trace.start + Vector( 0, 0, -128 );
			trace.filter = ent;
			local tr = util.TraceLine( trace );
			
			if( tr.Entity and tr.Entity:IsValid() and tr.Entity.GravityPlating ) then
				
				if( ent.CurrentGravity != tr.Entity.GravityPlatingForce ) then
					
					ent.CurrentGravity = tr.Entity.GravityPlatingForce;
					ent:SetGravity( tr.Entity.GravityPlatingForce + 0.0001 );
					
				end
				
			elseif( ent.CurrentGravity != 0 ) then
				
				ent.CurrentGravity = 0;
				ent:SetGravity( 0.0001 );
				
			end
			
			return;
			
		end
		
		if( ent.CurrentGravity != C.MapObjects.Planets[planet].gravity ) then
			
			ent.CurrentGravity = C.MapObjects.Planets[planet].gravity;
			ent:SetGravity( C.MapObjects.Planets[planet].gravity + 0.0001 );
			
		end
		
	end
	
	local phys = ent:GetPhysicsObject();
	
	if( ent.CurrentGravity == nil ) then
		
		ent.CurrentGravity = true;
		
	end
	
	local planet = C.InPlanet( ent );
	
	if( planet == 0 and ent.CurrentGravity ) then
		
		phys:EnableGravity( false );
		ent.CurrentGravity = false;
		
	elseif( planet != 0 and !ent.CurrentGravity ) then
		
		phys:EnableGravity( true );
		phys:Wake();
		ent.CurrentGravity = true;
		
	end
	
end